package com.example.springbook.service;


import com.example.springbook.bean.User;
import com.example.springbook.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public boolean addUser(User user){
        boolean flag=false;
        try{ userDao.addUser(user); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public boolean updateUser(User user) {
        boolean flag=false;
        try{ userDao.updateUser(user); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public boolean deleteUser(int id) {
        boolean flag=false;
        try{ userDao.deleteUser(id); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public List<User> findAllUser() {
        return userDao.findAllUser();
    }

    @Override
    public String selectUser(int id){ return userDao.selectUser(id);}

    @Override
    public String findUserName(int id){ return userDao.findUserName(id);}
}
